package com.matt.domain.course;

import com.matt.foundation.constant.CourseConstant;
import com.matt.commons.model.Domain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import java.util.Date;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/3/16
 * *******************************
 */
@Entity
@Table(name = "course_plan_classes")
@Data
@EqualsAndHashCode(callSuper = true)
public class CoursePlanClasses extends Domain{
    @Column(columnDefinition = " int DEFAULT 0 COMMENT ' 备课状态： 0:未备课,1:已备课 2:待审核, 3:未通过, 4:已通过 ' ")
    private Integer prepareStatus = 0;

    @Column(columnDefinition = " int DEFAULT 0 COMMENT ' 上课状态 0：未上，1：已上 ' ") //这是托班课程
    private Integer courseStatus = 0; //如果是早教课 状态  0：进行中,1：已完成，2：未处理

    @Column(columnDefinition = " varchar(255) COMMENT ' 类型名称 ' ")
    private String typeName;

    @Column(columnDefinition = " varchar(255) COMMENT ' 课程名称 ' ")
    private String courseName;

    @Column(columnDefinition = " datetime  COMMENT ' 开始时间 ' ")
    private Date beginTime;

    @Column(columnDefinition = " datetime  COMMENT ' 结束时间 ' ")
    private Date endTime;

    @Column(columnDefinition = " datetime  COMMENT ' 课程时间 ' ")
    private Date courseDate;

    @Column(columnDefinition = " int DEFAULT 1 COMMENT ' 类型：1，SAT早教课程，2，园区自建，3，公共课程 ' ")
    private Integer courseType;

    @Column(columnDefinition = " varchar(32) COMMENT ' 对应课程id ' ")
    private String courseId;

    @Column(columnDefinition = " varchar(32) COMMENT ' 对应班级id ' ")
    private String classesId;

    @Column(columnDefinition = " varchar(32) COMMENT ' 对应园区id ' ")
    private String areaId;

    @Column(columnDefinition = " varchar(32) COMMENT ' 对应主题课程id ' ")
    private String coursePlanTopicId;

    @Column(columnDefinition = " varchar(32) COMMENT ' 开始上课老师id ' ")
    private String beginCourseTeacherId;

    @Column(columnDefinition = " datetime  COMMENT ' 开始上课时间 ' ")
    private Date beginCourseTime;

    @Column(columnDefinition = "int DEFAULT 1 COMMENT '类型：1：托班，2：早教'")
    private Integer category;

    @javax.persistence.Transient
    private int templateType;

    @Transient
    private Integer type;
    @Transient
    private Integer typeCode;

    public static CoursePlanClasses of(String courseId, String classesId, String areaId){
        CoursePlanClasses nurseryClasses = new CoursePlanClasses();
        nurseryClasses.setCourseId(courseId);
        nurseryClasses.setAreaId(areaId);
        nurseryClasses.setClassesId(classesId);
        return nurseryClasses;
    }

    public static CoursePlanClasses ofEarly(Date beginTime, Date endTime, Date courseDate, Integer courseType, String courseId, String classesId, String areaId){
        CoursePlanClasses planClasses = new CoursePlanClasses();
        planClasses.setBeginTime(beginTime);
        planClasses.setEndTime(endTime);
        planClasses.setCourseDate(courseDate);
        planClasses.setCourseType(courseType);
        planClasses.setCourseId(courseId);
        planClasses.setAreaId(areaId);
        planClasses.setClassesId(classesId);
        return planClasses;
    }

    public static CoursePlanClasses ofTopic(CoursePlanTopic planTopic, String areaId, String classesId){
        CoursePlanClasses planClasses = new CoursePlanClasses();
        planClasses.setTypeName(planTopic.getTypeName());
        planClasses.setCourseName(planTopic.getCourseName());
        planClasses.setBeginTime(planTopic.getBeginTime());
        planClasses.setEndTime(planTopic.getEndTime());
        planClasses.setCourseDate(planTopic.getCourseDate());
        planClasses.setCourseType(planTopic.getCourseType());
        planClasses.setCourseId(planTopic.getCourseId());
        planClasses.setCoursePlanTopicId(planTopic.getId());
        planClasses.setClassesId(classesId);
        planClasses.setAreaId(areaId);
        planClasses.setCategory(CourseConstant.Category.NURSERY.codeOf());
        return planClasses;
    }

    public static CoursePlanClasses ofOldCoursePlanClass(CoursePlanClasses old){
        CoursePlanClasses coursePlanClasses = new CoursePlanClasses();
        coursePlanClasses.setTypeName(old.getTypeName());
        coursePlanClasses.setCourseName(old.getCourseName());
        coursePlanClasses.setCourseDate(old.getCourseDate());
        coursePlanClasses.setBeginTime(old.getBeginTime());
        coursePlanClasses.setEndTime(old.getEndTime());
        coursePlanClasses.setCourseType(old.getCourseType());
        coursePlanClasses.setCourseId(old.getCourseId());
        coursePlanClasses.setClassesId(old.getClassesId());
        coursePlanClasses.setAreaId(old.getAreaId());
        coursePlanClasses.setCoursePlanTopicId(old.getCoursePlanTopicId());
        coursePlanClasses.setCategory(old.getCategory());

        return coursePlanClasses;
    }
}
